package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

class zamn {
   private IStreamProvider a;
   private HashMap b = null;

   public zamn(IStreamProvider var1) {
      this.a = var1;
   }

   public void a(String var1, Workbook var2, LoadOptions var3) throws Exception {
      zanl var4 = new zanl();
      ((zbps)this.a).a(var4.a(var1, Encoding.getUTF8()));
      this.a(var2, var3);
   }

   public void a(com.aspose.cells.b.a.d.zm var1, Workbook var2, LoadOptions var3) throws Exception {
      zanl var4 = new zanl();
      ((zbps)this.a).a(var4.a(var1, Encoding.getUTF8()));
      this.a(var2, var3);
   }

   private void a(Workbook var1, LoadOptions var2) throws Exception {
      ArrayList var3 = ((zbps)this.a).a();
      String var4 = "filelist.xml";
      com.aspose.cells.b.a.d.zm var5 = this.a(var3, var4);
      if (var3.size() > 1 && var5 != null) {
         zcfk var12 = zass.a((com.aspose.cells.b.a.d.zm)var5, (zcft)null, false);
         zcfs var13 = var12.e("o:MainFile");
         zcfl var14 = (zcfl)var13.a(0);
         String var15 = zase.a((zcfq)var14, (String)"HRef");
         String var16 = var15.substring(var15.lastIndexOf("/") + 1);
         com.aspose.cells.b.a.d.zm var11 = this.a(var3, var16);
         this.b(var11, var1, var2);
      } else if (var3.size() == 1) {
         this.b(((zank)var3.get(0)).b, var1, var2);
      } else {
         Iterator var6 = var3.iterator();
         this.b = new HashMap();

         label46:
         while(true) {
            zank var7;
            do {
               if (!var6.hasNext()) {
                  var6 = var3.iterator();

                  while(var6.hasNext()) {
                     var7 = (zank)var6.next();
                     if ("text/html".equals(var7.c) && var7.b.d()) {
                        this.b(var7.b, var1, var2);
                     }
                  }
                  break label46;
               }

               var7 = (zank)var6.next();
            } while(var7.c.indexOf("css") == -1);

            zafc var8 = new zafc(var7.b, var1, new HTMLLoadOptions(), Encoding.getUTF8());
            var8.a(this.a);
            var8.q().a(var7.b);
            Iterator var9 = var8.q().e().H().entrySet().iterator();

            while(var9.hasNext()) {
               com.aspose.cells.b.a.a.za var10 = (com.aspose.cells.b.a.a.za)var9.next();
               if (this.b.containsKey(var10.getKey())) {
                  this.b.put(var10.getKey(), var10.getValue());
               } else {
                  this.b.put(var10.getKey(), var10.getValue());
               }
            }
         }
      }

   }

   private void b(com.aspose.cells.b.a.d.zm var1, Workbook var2, LoadOptions var3) throws Exception {
      try {
         zafc var4 = new zafc(var1, var2, new HTMLLoadOptions(), Encoding.getUTF8());
         var4.a(this.a);
         if (this.b != null) {
            var4.q().e().s(this.b);
         }

         var4.m();
         var4.q().e().z();
         if (this.a(var4)) {
            var4.a(var4.q(), var2, Encoding.getUTF8());
         }
      } finally {
         if (var1 != null) {
            var1.a();
         }

      }

   }

   private com.aspose.cells.b.a.d.zm a(ArrayList var1, String var2) {
      Iterator var3 = var1.iterator();

      while(var3.hasNext()) {
         zank var4 = (zank)var3.next();
         String var5 = var4.a;
         if (var5 != null) {
            String[] var6 = com.aspose.cells.b.a.zv.d(var5, '/');
            if (var6[var6.length - 1].equals(var2)) {
               return var4.b;
            }
         }
      }

      return null;
   }

   private boolean a(zafc var1) {
      Iterator var2 = var1.q().d().values().iterator();

      com.aspose.cells.b.a.d.zm var3;
      do {
         if (!var2.hasNext()) {
            return false;
         }

         var3 = (com.aspose.cells.b.a.d.zm)var2.next();
      } while(var3 == null);

      return true;
   }
}
